/*
File: COptiontsState.cpp
Author: Corey Morehead
Date: April 04, 2013
Purpose: State to handle Options
*/

#include "../source/CreditState.h"
#include <cassert>
#include "../source/IAudio.h"
#include "../source/IGraphics.h"
#include "../source/IInput.h"
#include "../source/Constants.h"
#include "../source/Resources.h"
#include "../source/IGameStateMachine.h"

CreditState* CreditState::s_Instance = NULL;

 IGameState* CreditState::GetInstance(void)
{
	if( CreditState::s_Instance == NULL )
		CreditState::s_Instance = new CreditState;
	return CreditState::s_Instance;
}

void CreditState::DeleteInstance(void)
{
	delete CreditState::s_Instance;
	CreditState::s_Instance = NULL;
}

CreditState::CreditState( void )
{
	m_pAudio			= NULL;
	m_pGraphics			= NULL;
	m_pInput			= NULL;	
	m_pWorld			= NULL;
	m_hTexture			= HTexture();
}

CreditState::~CreditState( void ) { }

bool CreditState::Enter( void )
{
	m_pAudio = IAudio::GetInstance();
	m_pGraphics = IGraphics::GetInstance();
	m_pInput = IInput::GetInstance();

	// Load testing file
	m_hTexture = m_pGraphics->LoadTexture( GRAPHICS_PATH( "CreditsState" ) );
	assert( m_hTexture != INVALID_HANDLE && "CreditsState::Enter - could not load CreditState image" != 0 );

	if( m_hTexture == INVALID_HANDLE )
		return false;

	return true;
}

bool CreditState::Exit( void )
{
	m_pGraphics->UnloadTexture( m_hTexture );
	m_hTexture = HTexture();

	return true;
}

bool CreditState::Input( float fElapsedTime )
{
	(void)fElapsedTime;

	if( m_pInput->ButtonPressed( IInput::E_SELECT ) == true )
		return false;
	/*
	E_DPAD_UP, E_DPAD_DOWN, E_DPAD_LEFT, E_DPAD_RIGHT, E_FACE_UP, E_FACE_DOWN, E_FACE_LEFT,
	E_FACE_RIGHT, E_LEFT_SHOULDER, E_RIGHT_SHOULDER, E_LEFT_THUMB, E_RIGHT_THUMB, E_START,
	E_SELECT, E_NUM_BUTTONS
	*/
	//E_MAINMENU, E_GAMEPLAY, E_OPTIONS, E_HOWTOPLAY, E_HIGHSCORES, E_CREDITS

		if( m_pInput->ButtonPressed( IInput::E_DPAD_LEFT ) == true )
		return IGameStateMachine::GetInstance()->SwitchState( IGameStateMachine::E_OPTIONS );
	//else if( m_pInput->ButtonPressed( IInput::E_START ) == true )
	//	return IGameStateMachine::GetInstance()->SwitchState( IGameStateMachine::E_GAMEPLAY );
	//else if ( m_pInput->ButtonPressed (IInput::E_DPAD_UP) == true)
	//	return IGameStateMachine::GetInstance()->SwitchState(IGameStateMachine::E_HIGHSCORES);
	//else if (m_pInput->ButtonPressed (IInput::E_DPAD_RIGHT) == true)
	//	return IGameStateMachine::GetInstance()->SwitchState(IGameStateMachine::E_CREDITS);

	return true;
}

bool CreditState::Update( float fElapsedTime )
{
	(void)fElapsedTime;	
	return true;
}

bool CreditState::Render( float fElapsedTime )
{	
	(void)fElapsedTime;
	m_pGraphics->DrawTexture( m_hTexture, 0, 0, 0, 0, 0, SColor(), 2, 2 );
	return true;
}